// Display a vertical bar graph rpresenting a range from -5000 to +5000
// the actual value is a random number within that range

#include "../../ACUAS/ACUAS.h"
#include "../../ACUAS/ACUASlcd2.h"

PROGRAM_INIT
	int i,y;
	RANDOM_INIT							// initialize random number generation

	ACTIVATE_LCD
	CLEAR_LCD
	LCD_BAR_V_INIT						// initialize the vertical bar graph (define the needed special characters)
	LCD_XY(1,1)
	for(i=0;i<8;i++) LCD_CHAR(i)		// display the special characters
	LCD_XY(1,2)
	LCD_TEXT("Joystick down")			// wait untile joystick is moved down (and released)
	WAIT_FOR_JOYSTICK_DOWN

	CLEAR_LCD
	LCD_XY(11,1) LCD_TEXT("+5000")		// indicate the range
	LCD_XY(11,2) LCD_TEXT("-5000")

PROGRAM_START
WAIT_SEC(1)
	y = RANDOM(-5000,5000);				// store a random number between -5000 and +5000 in the variable y
	LCD_BAR_V(y,-5000,5000,9)			// display the vertical bar graph of the value y at column 9
	LCD_XY(1,2) 
	if(y>=0) LCD_CHAR('+')				// display the value of y as a number
	LCD_NUMBER(y) LCD_TEXT("   ")

PROGRAM_END

